
import std.stdio:writefln;

import std.string: toStringz;

import maths.Vec;

import utils.Singleton;

import derelict.sdl.sdl;
import derelict.opengl.gl;

class Screen{
	mixin SingletonMix;
	SDL_Surface *scr;
	uint width = 8;
	uint height = 6;
	uint bitsPerPixel = 32;
	bool fullscreen = false;
	uint background = 0x7F7F7F;
	char[] caption = "LOD";
	private bool mustLock = true;

	void initialize(){
		initSDL();

		DerelictGL.loadVersions(GLVersion.Version20);
	}

	private void initSDL(){
		uint sdlFlags = SDL_HWSURFACE;
		DerelictSDL.load();

		if(fullscreen)
			sdlFlags |= SDL_FULLSCREEN;

		sdlFlags |= SDL_OPENGL;

		SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
		scr = SDL_SetVideoMode(width, height, bitsPerPixel, sdlFlags );
		SDL_WM_SetCaption(toStringz(caption), null);
	}

	~this(){
		SDL_Quit();
		DerelictSDL.unload();
	}


}

alias SingletonGetter!(Screen) screen;
